public class dlms {

    public static void main(String[] args) {
        Singlenton s=  Singlenton.getInstance();
    }
}
class Singlenton{
    //防止空指针异常
    private volatile  static Singlenton instance;
    private Singlenton(){

    }
    public static Singlenton getInstance(){
        //双重检查锁 大多数读就可以了-避免性能浪费
        if(instance==null){
            synchronized (Singlenton.class)
            {
                if(instance==null)
                {
                    instance=new Singlenton();
                }
            }
        }
        return instance;
    }


}
